Metaparse Compile-time parsing with template metaprogramming

نویسندگان

  • Ábel Sinkovics
  • Zoltán Porkoláb
چکیده

Metaparse is a C++ template metaprogramming library for generating parsers, which are template metaprograms themselves parsing strings at C++ compile-time. Parsers built with Metaparse take free-formed strings as input and parse them at compile-time, thus it is possible to build a parser and apply it in the same session of compilation. The C++11 standard provides constexpr, a construct for executing algorithms at compile-time. We present the connection between metaprogramming and constexpr and utilise it to minimise the syntactical overhead of the input processed by the parsers. Thus Metaparse is capable to solve a wide variety of tasks – from applying syntactical sugars for existing metaprograms to DSL integrations. An accurate error reporting helps Metaparse users to detect parsing errors. All solutions presented in this paper are implemented as an open source library and are available for the reader.

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Fake Run-Time Selection of Template Arguments in C++

C++ does not support run-time resolution of template type arguments. To circumvent this restriction, we can instantiate a template for all possible combinations of type arguments at compile time and then select the proper instance at run time by evaluation of some provided conditions. However, for templates with multiple type parameters such a solution may easily result in a branching code bloa...

متن کامل

Strictness Analysis and let-to-case Transformation using Template Haskell

Metaprogramming consists of writing programs that generate or manipulate other programs. Template Haskell is a very recent extension of Haskell, currently implemented in the Glasgow Haskell Compiler, giving support to metaprogramming at compile time. Our aim is to apply these facilities in order to statically analyse programs and transform them at compile time. In this paper we use Template Has...

متن کامل

Using Template Haskell for Abstract Interpretation

Metaprogramming consists of writing programs that generate or manipulate other programs. Template Haskell is a recent extension of Haskell, currently implemented in the Glasgow Haskell Compiler, giving support to metaprogramming at compile time. Our aim is to apply these facilities in order to statically analyse programs and transform them at compile time. In this paper we use Template Haskell ...

متن کامل

Enhancing DEVS simulation through template metaprogramming: DEVS-MetaSimulator

For several years, the DEVS community has been developing many tools for simulating DEVS models, ranging from local and sequential simulation to massively distributed and parallel simulation. In this paper, we present an innovative approach to local DEVS simulation. By using template metaprogramming, we developed the DEVS-MetaSimulator (DEVS-MS); instead of proposing one simulator meant to be u...

متن کامل

Metaprogramming Applied to Numerical Problems

Metaprogramming is a programming technique where a computer program is written that writes or manipulates another program (or itself) that then solves a given task. This approach has several advantages over classical programming. Firstly, it leads to more efficient programming because the process of generating code is automated as you basically write code that writes code. Secondly, it might al...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2012